package com.huawei.appmarket.service.selfupdate;

import android.content.Context;
import android.content.Intent;
import android.os.Message;
import android.os.Parcelable;
import com.huawei.appgallery.foundation.ui.framework.activity.AbstractBaseActivity;
import com.huawei.appgallery.packagemanager.api.bean.ManagerTask;
import com.huawei.secure.android.common.intent.SafeBroadcastReceiver;
import o.coa;
import o.cod;
import o.Logger;
import o.ContentManager;
import o.dsl;
import o.dwp;
import o.eba;
import o.fho;
import o.fhz;

public class ClientInstallReceiver extends SafeBroadcastReceiver {
    public void onReceiveMsg(Context context, Intent intent) {
        String action = intent.getAction();
        if ("PackageManager.action.CLIENT_SELF_INSTALL_EXECPTION".equals(action)) {
            dsl.ॱ();
        } else if ("PackageManager.action.CLIENT_SELF_INSTALL".equals(action)) {
            ˋ(context);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                Logger.ˏ("ClientInstallReceiver", e.toString());
            }
            dsl.ˏ();
            AbstractBaseActivity.sendUpgrade(ContentManager.getInstant().getContext());
        } else if ("PackageManager.action.PACKAGE_MSG_DISPATCH".equals(action)) {
            Parcelable parcelableExtra = intent.getParcelableExtra("PackageManager.extra.PARCELABLE_MESSAGE");
            if (parcelableExtra instanceof Message) {
                Message message = (Message) parcelableExtra;
                Object obj = message.obj;
                if (obj instanceof ManagerTask) {
                    dwp.ॱ((ManagerTask) obj, message.arg1, message.arg2);
                }
            }
        }
    }

    private void ˋ(Context context) {
        int i = 2;
        fhz ˋ = fho.ˏ().ˋ("PackageManager");
        if (ˋ != null) {
            coa o_coa = (coa) ˋ.ॱ(coa.class);
            if (o_coa != null) {
                ManagerTask ˎ = o_coa.ˎ(context.getPackageName(), cod.INSTALL);
                if (ˎ != null) {
                    eba ˋ2 = eba.ˋ();
                    Context ˋ3 = ContentManager.getInstant().getContext();
                    String str = ˎ.packageName;
                    Object obj = ˎ.ॱॱ;
                    if (ˎ.ᐝ != 2) {
                        i = 1;
                    }
                    ˋ2.ˏ(ˋ3, str, obj, i, ˎ.ʻ);
                }
            }
        }
    }
}
